
/**
 * AppleIIGo
 * Internal ACIA class
 * (C) 2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#include "InternalACIA.h"

InternalACIA::InternalACIA(Motherboard * motherboard,
						   char * slotDeviceName) :
SlotDevice(motherboard, slotDeviceName) {
}

void InternalACIA::onResetAsserted(bool isRestart) {
	dataRegister = 0;
	statusRegister = 0;
	commandRegister = 0;
	controlRegister = 0;
}

void InternalACIA::writeIo(UINT16 address, UINT8 value) {
	switch (address & 0x3) {
		case 0x0:
			dataRegister = value;
		case 0x1:
			break;
		case 0x2:
			commandRegister = value;
			break;
		case 0x3:
			controlRegister = value;
			break;
	}
}

UINT8 InternalACIA::readIo(UINT16 address) {
	switch (address & 0x3) {
		case 0x0:
			return dataRegister;
		case 0x1:
			return statusRegister;
		case 0x2:
			return commandRegister;
		case 0x3:
			return controlRegister;
	}
	
	return timingGenerator->readFloatingBus();
}
